package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(37)
public class MeiyoushanGameStrategy extends BaseGameStrategy {

    public static final String URL = "http://114.66.45.141:30581/gmss/vip/api.php";


    /**
     * 物品
     sqm: diyao88
     usr: v111222
     num: 11
     lv:
     item: 100
     quid: 1
     gnxz: 2
     * @param item
     * @return
     */
    @GongnengMethod(3702)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("sqm", "diyao88");
        params.add("usr", item.uid);
        params.add("num", item.number);
        params.add("item", item.itemId);
        params.add("gnxz", "2");
        params.add("quid", "1");
        String s = RestTemplateUtil.sendPostForm(URL, params);
        return s;
    }

    /**
     * 充值
     * sqm: diyao88
     * usr: m66666
     * bao: 110
     * num: 1
     * lv: 1
     * item: 101
     * quid: 1
     * gnxz: 2
     * @param item
     * @return
     */
    @GongnengMethod(3701)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("sqm", "diyao88");
        params.add("usr", item.uid);
        params.add("bao", item.itemId);
        params.add("gnxz", "1");
        params.add("quid", "1");
        String s = RestTemplateUtil.sendPostForm(URL, params);
        return s;
    }


    @GongnengMethod(3703)
    public String zhuangbei(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("sqm", "diyao88");
        params.add("usr", item.uid);
        params.add("num", "1");
        params.add("lv", item.number);
        params.add("item", item.itemId);
        params.add("gnxz", "2");
        params.add("quid", "1");
        String s = RestTemplateUtil.sendPostForm(URL, params);
        return s;
    }

    public static void main(String[] args) {
        MeiyoushanGameStrategy strategy = new MeiyoushanGameStrategy();
        SendItem item = new SendItem();
        item.uid = "m66666";
        item.itemId = "210";
        item.number = "1";
        String pay = strategy.pay(item);
        System.out.println(pay);
    }
}

